<link href="/css/global/form.css" media="screen" rel="stylesheet" type="text/css"/>
<link href="/css/oa/page_userinserting.css" media="screen" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="script/jquery.min.js"></script>
<script type="text/javascript" src="/script/global/form.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		showLoading();
		$.getJSON("/login/getSchools", function(data){
			for (var i = 0; i < data.length; i ++)
				$("#user_school #input_school").append("<option value='" + data[i][0] + "'>" + data[i][1] + "</option>");
			hideLoading();
		});

		showLoading();
		$.getJSON("/login/getProfessions", function(data){
			for (var i = 0; i < data.length; i ++)
				$("#user_profession #input_profession").append("<option value='" + data[i][0] + "'>" + data[i][1] + "</option>");
			hideLoading();
		});
	});

	function addUser(){
		$.post("/oa/insertUser", {"fidocard" : $("#input_fidocard").val(), "mobile" : $("#input_mobile").val(),
									"name" : $("#input_name").val(), "gender" : $("#input_gender:checked").val(),
									"birthday" : $("#input_birthday").val(), "email" : $("#input_email").val(),
									"school" : $("#input_school").val(), "profession" : $("#input_profession").val(),
									"grade" : $("#input_grade").val()},
			function(data){
				if (data == 'success'){
					$("table#addedusers").append("<tr><td>" + $("#input_fidocard").val() + "</td><td>" + $("#input_mobile").val() + 
												"</td><td>" + $("#input_name").val() + "</td><td>" + $("#input_gender:checked").val() + 
												"</td><td>" + $("#input_birthday").val() + "</td><td>" + $("#input_email").val() + 
												"</td></tr>");
				}  else {
					showError("错误：" + data + "。");
				} 
			});
	}
</script>
<div id="adduser">
	<form id="form_adduser">
		<div class="notify_all_ok" style="display:none;"></div>
		<div class="notify_all_error" style="display:none;"></div>
		<fieldset id="user">
			<legend>用户录入</legend>
			<div id="user_fidocard">
				<label for="fidocard">Fido卡号</label>
				<input type="text" id="input_fidocard" name="fidocard" />
			</div>

			<div id="user_mobile">
				<label>手机号</label>
				<input type="input" id="input_mobile" name="mobile" />
			</div>
			
			<div id="user_name">
				<label>姓名</label>
				<input type="input" id="input_name" name="name" />
			</div>

			<div id="user_gender">
				<label>性别</label>
				<input type="radio" name="input_gender" id="input_gender" value="male">男</input>
				<input type="radio" name="input_gender" id="input_gender" value="female">女</input>
			</div>
			
			<div id="user_birthday">
				<label>生日</label>
				<input type="input" id="input_birthday" name="birthday" />
			</div>

			<div id="user_email">
				<label>邮箱</label>
				<input type="input" id="input_email" name="email" />
			</div>
			
			<div id="user_school">
				<label>学校</label>
				<select id="input_school" style="moz-border-radius:3px;border:1px solid #DDDDDD;width:160px;margin:0;">
				</select>
			</div>

			<div id="user_profession">
				<label>专业</label>
				<select id="input_profession" style="moz-border-radius:3px;border:1px solid #DDDDDD;width:160px;margin:0;">
				</select>
			</div>
			
			<div id="user_grade">
				<label>年级</label>
				<input type="input" id="input_grade" name="grade" />
			</div>
			
			<div id="bottom_buttons">
				<button type="button" id="button_submit" style="margin-left:160px;" onclick="javascript:addUser()">确认</button>
			</div>
		</fieldset>
	</form>
</div>
<div id="addedusers">
	<table id="addedusers" border="1">
		<tr>
			<th width="100px">Fido卡号</th>
			<th width="100px">手机号</th>
			<th width="100px">姓名</th>
			<th width="100px">性别</th>
			<th width="100px">生日</th>
			<th width="200px">邮箱</th>
		</tr>
	</table>
</div>